package com.yanqu.road.server.manger.scenecard;

import com.alibaba.fastjson.JSONObject;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.UserActivityConditionData;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.player.PlayerState;
import com.yanqu.road.entity.player.UserCard;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.entity.scenecard.PlayerRewardData;
import com.yanqu.road.entity.scenecard.SceneCardConfig;
import com.yanqu.road.entity.scenecard.SceneCardPlayerData;
import com.yanqu.road.logic.bussiness.activity.SceneCardBusiness;
import com.yanqu.road.logic.bussiness.player.UserActivityBussiness;
import com.yanqu.road.logic.bussiness.player.UserCardBussiness;
import com.yanqu.road.logic.config.ChannelConfig;
import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.manger.ServerListMgr;
import com.yanqu.road.server.manger.activity.ActivityInfoMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.player.PrivilegeCardMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.utils.ConfigHelper;
import com.yanqu.road.utils.MD5Security;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.executor.ScheduledThreadPoolHelper;
import com.yanqu.road.utils.http.HttpHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SceneCardMgr extends TempMgr {

    /**
     * 卡片推送消息 k:cardId v:card推送信息
     */
    private static Map<Integer, SceneCardPlayerData> cardSubscribeMap = new ConcurrentHashMap<>();

    private static ScheduledThreadPoolExecutor messageSendExecutor = ScheduledThreadPoolHelper.createGameScheduledThreadPoolExecutor(1, "sceneCard");

    private static int gameId = 180;

    private static String sign = "g_tX23pC9c2256ea,vy_58RPQR6AZ!r~"; // 37 提供签名 key

    private static Logger logger = LogManager.getLogger(SceneCardMgr.class);

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        cardSubscribeMap = SceneCardBusiness.getSceneCardPlayerData();
        if (cardSubscribeMap == null) {
            cardSubscribeMap = new ConcurrentHashMap<>();
        }
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    @Override
    public boolean save() {
        for (SceneCardPlayerData data : cardSubscribeMap.values()) {
            if (data.isInsertOption()) {
                SceneCardBusiness.addSceneCardPlayerData(data);
            } else if (data.isUpdateOption()) {
                SceneCardBusiness.updateSceneCardPlayerData(data);
            }
        }
        return true;
    }

    /**
     * 是否开启这个功能
     * 1. 判断渠道号、是否是正式环境
     *
     * @return
     */
    private static boolean isSwitch() {
        long serverId = ConfigHelper.getLong("serverId");
        int channelId = ServerListMgr.getChannelId(serverId);
        // TODO 是否是正式环境
        // 判断抖音渠道 id
        return eChannelType.isDYChannel(channelId) && ChannelConfig.DOUYIN_SCENE_CARD_SWITCH == 1;
    }

    /**
     * 尝试发送一些定时的推送
     */
    public static void attemptSend() {
        // 尝试推送
        for (SceneCardConfig item : SceneCardConfig.values()) {
            SceneCardConfig sceneCardConfig = SceneCardConfig.forNumber(String.valueOf(item.getCardId()));
            if (sceneCardConfig == null) { // 不存在配置
                continue;
            }
            // 当天以及时间在上次触发之前 跳过
            SceneCardPlayerData cardSubscribeData = getCardSubscribeData(item.getCardId());
            if (!canCardSend(cardSubscribeData)) {
                continue;
            }
            cardSubscribeData.setTouchTime(System.currentTimeMillis()); // 当前的触发时间
            // 过滤出卡片项预期玩家
            List<UserInfo> playerData = getPlayerListByCard(item);
            logger.info("场景游戏卡类型:{},推送预期玩家数量:{}", item.getGameTitle(), playerData.size());
            if (!playerData.isEmpty()) {
                if (item.getCardId() == SceneCardConfig.SevenSign.getCardId()) {
                    // 推送七日签到奖励
                    pushSevenSignActivityCard(sceneCardConfig, playerData);
                }
                if (item.getCardId() == SceneCardConfig.MonthCard.getCardId()) {
                    // 推送月卡奖励
                    pushMonthCardCard(sceneCardConfig, playerData);
                }
                if (item.getCardId() == SceneCardConfig.YearCard.getCardId()) {
                    // 推送年卡奖励
                    pushYearCardCard(sceneCardConfig, playerData);
                }
            }
        }
    }

    private static void pushSevenSignActivityCard(SceneCardConfig sceneCardConfig, List<UserInfo> playerDataList) {
        // 判断活动生效时间
        List<ActivityInfo> activityInfoList = NormalActivityMgr.getOpenActivityInfoList(eActivityType.DaySign.getValue());
        if (activityInfoList.isEmpty()) {
            getLogger().info("no seven sign activity in show time.");
            return;
        }

        ActivityInfo activityInfo = null;
        for (ActivityInfo activityInfoTemp : activityInfoList) {
            if (ActivityMgr.activityInTime(activityInfoTemp)) {
                activityInfo = activityInfoTemp;
                break;
            }
        }
        if (activityInfo == null) {
            return;
        }

        // 根据七日卡片配置需要第2天 第5天 第6天 第7天的奖励
        ArrayList<String> conditionList = new ArrayList<>();
        conditionList.add("2");
        conditionList.add("5");
        conditionList.add("6");
        conditionList.add("7");

        Map<String, ArrayList<Long>> sendMap = new HashMap<>();
        Map<String, List<BigInteger>> rewardCountMap = new HashMap<>();
        for (String day : conditionList) {
            ArrayList<BigInteger> arrayList = getRewardCount(day, sceneCardConfig.getCardId());
            rewardCountMap.put(day, arrayList);
        }
        for (UserInfo userInfo : playerDataList) {
            String regExp = "[0-9]*";
            Matcher m = Pattern.compile(regExp).matcher(userInfo.getPlatformUserId());
            if (!m.matches()) {
                continue;
            }
            // 判断玩家当前签到天数是否在卡片配置范围内 1-7
            List<UserActivityConditionData> conditionDataList = getDaySignData(activityInfo.getActivityId(), userInfo.getUserId());
            if (conditionDataList.size() <= 1) { // 签到天数小于2
                String fixDay = "2";
                if (!sendMap.containsKey(fixDay)) {
                    sendMap.put(fixDay, new ArrayList<>());
                }
                sendMap.get(fixDay).add(Long.parseLong(userInfo.getPlatformUserId()));
                if (sendMap.get(fixDay).size() >= 100) { // 100个推送一次
                    List<BigInteger> list = rewardCountMap.get(fixDay);
                    ArrayList<Long> uids = sendMap.get(fixDay);
                    PlayerRewardData rewardData = getPlayerRewardData(list, getRewardIndex(fixDay, sceneCardConfig.getCardId()), uids);
                    sendSceneCard(sceneCardConfig, rewardData);
                    sendMap.remove(fixDay);
                }
            } else {
                List<Integer> dayList = new ArrayList<>();
                for (UserActivityConditionData conditionData : conditionDataList) {
                    List<Integer> list = StringUtils.stringToIntegerList(conditionData.getParam(), "\\|");
                    if (list.isEmpty() || list.size() < 3){
                        continue;
                    }
                    dayList.add(list.get(2));
                }
                if (dayList.isEmpty()) {
                    continue;
                }
                String day = "";
                if (conditionDataList.size() < 7) {
                    if (conditionDataList.size() <= 1 && !dayList.contains(2)) {
                        day = "2";
                    } else if (conditionDataList.size() <= 4 && !dayList.contains(5)) {
                        day = "5";
                    } else if (conditionDataList.size() <= 5 && !dayList.contains(6)) {
                        day = "6";
                    } else {
                        if (!dayList.contains(7)){
                            day = "7";
                        }
                    }
                    if (day.isEmpty()) {
                        continue;
                    }
                    if (!sendMap.containsKey(day)) {
                        sendMap.put(day, new ArrayList<>());
                    }
                    sendMap.get(day).add(Long.parseLong(userInfo.getPlatformUserId()));
                    if (sendMap.get(day).size() >= 100) { // 100个推送一次
                        List<BigInteger> list = rewardCountMap.get(day);
                        ArrayList<Long> uids = sendMap.get(day);
                        PlayerRewardData rewardData = getPlayerRewardData(list, getRewardIndex(day, sceneCardConfig.getCardId()), uids);
                        sendSceneCard(sceneCardConfig, rewardData);
                        sendMap.remove(day);
                        //logger.info("批量推送成功");
                    }
                }
            }
        }
        // 多余出来的直接发送
        pushPlayerLow100(sceneCardConfig, sendMap, rewardCountMap);
    }

    private static void pushMonthCardCard(SceneCardConfig sceneCardConfig, List<UserInfo> playerDataList) {
        pushCard(sceneCardConfig, playerDataList);
    }

    private static void pushYearCardCard(SceneCardConfig sceneCardConfig, List<UserInfo> playerDataList) {
        pushCard(sceneCardConfig, playerDataList);
    }

    /*
     * pushCard 推送
     */
    private static void pushCard(SceneCardConfig sceneCardConfig, List<UserInfo> playerDataList) {
        Map<String, ArrayList<Long>> sendMap = new HashMap<>();
        Map<String, List<BigInteger>> rewardCountMap = new HashMap<>();
        for (UserInfo userInfo : playerDataList) {
            // 月卡每日领取
            String rewardIndex = "1";
            ArrayList<BigInteger> arrayList = getRewardCount(rewardIndex, sceneCardConfig.getCardId());
            rewardCountMap.put(rewardIndex, arrayList);

            if (!sendMap.containsKey(rewardIndex)) {
                sendMap.put(rewardIndex, new ArrayList<>());
            }
            String regExp = "[0-9]*";
            Matcher m = Pattern.compile(regExp).matcher(userInfo.getPlatformUserId());
            if (!m.matches()) {
                continue;
            }
            sendMap.get(rewardIndex).add(Long.parseLong(userInfo.getPlatformUserId()));
            if (sendMap.get(rewardIndex).size() >= 100) { // 100个推送一次
                List<BigInteger> list = rewardCountMap.get(rewardIndex);
                ArrayList<Long> openIds = sendMap.get(rewardIndex);
                PlayerRewardData rewardData = getPlayerRewardData(list, rewardIndex, openIds);
                sendSceneCard(sceneCardConfig, rewardData);
                sendMap.remove(rewardIndex);
            }
        }
        // 多余出来的直接发送
        pushPlayerLow100(sceneCardConfig, sendMap, rewardCountMap);
    }

    /*
     * 获取七日签到已签内容
     */
    private static List<UserActivityConditionData> getDaySignData(int activityId, long userId) {
        List<UserActivityConditionData> ret = new ArrayList<>();
        List<UserActivityConditionData> conditionDataList = UserActivityBussiness.getUserActivityConditionDataListByUserIdAndType(activityId, userId, eGamePlayerEventType.SpecialTombRobSevenDaySign.getValue());
        for (UserActivityConditionData conditionData : conditionDataList) {
            if (conditionData != null && conditionData.isGetReward()) {
                ret.add(conditionData);
            }
        }
        return ret;
    }

    /*
     * 能否推送
     */
    private static boolean canCardSend(SceneCardPlayerData playerData) {
        long now = System.currentTimeMillis();
        SceneCardPlayerData cardSubscribeData = getCardSubscribeData(playerData.getCardId());
        if (DateHelper.isSameDay(now, cardSubscribeData.getTouchTime())) { // 同一天的话代表触发过
            return false;
        }
        return isSwitch();
    }

    /*
     * pushPlayerLow100 推送小于100个的玩家数据
     */
    public static void pushPlayerLow100(SceneCardConfig sceneCardConfig, Map<String, ArrayList<Long>> sendMap, Map<String, List<BigInteger>> rewardCountMap) {
        for (Map.Entry<String, ArrayList<Long>> sendPlayer : sendMap.entrySet()) {
            String day = sendPlayer.getKey();
            List<BigInteger> list = rewardCountMap.get(day);
            ArrayList<Long> uids = sendMap.get(day);
            PlayerRewardData rewardData = getPlayerRewardData(list, getRewardIndex(day, sceneCardConfig.getCardId()), uids);
            sendSceneCard(sceneCardConfig, rewardData);
        }
    }

    /**
     * 根据对应场景卡片项获取对应批量玩家 根据对应配置
     *
     * @param sceneCardConfig
     * @return
     */
    public static List<UserInfo> getPlayerListByCard(SceneCardConfig sceneCardConfig) {
        List<UserInfo> playerList = new ArrayList<>();
        // 特殊检查逻辑
        if (!checkActivityCard(sceneCardConfig.getCardId())) {
            return playerList;
        }

        Map<Long, UserInfo> playerMap = UserMgr.getUserInfoMap();
        if (playerMap == null || playerMap.isEmpty()) {
            return playerList;
        }
        for (UserInfo userInfo : playerMap.values()) {
            if (checkPlayerCard(userInfo, sceneCardConfig.getCardId())) {
                playerList.add(userInfo);
            }
        }
        return playerList;
    }

    // 检查活动逻辑
    public static boolean checkActivityCard(int cardId) {
        if (cardId == SceneCardConfig.SevenSign.getCardId()) {
            // 判断活动生效时间
            List<ActivityInfo> list = NormalActivityMgr.getOpenActivityInfoList(eActivityType.DaySign.getValue());
            if (list.isEmpty()) {
                getLogger().info("no seven sign activity in show time.");
                return false;
            }
        }
        return true;
    }

    // 检查玩家逻辑
    public static boolean checkPlayerCard(UserInfo userInfo, int cardId) {
        GamePlayer onlinePlayer = GamePlayerMgr.getOnlinePlayer(userInfo.getUserId());
        if (onlinePlayer != null && onlinePlayer.getState() == PlayerState.ONLINE) {
            return false;
        }
        // TODO : ios 不支持推送
//        if (playerData.getDeviceplate().toLowerCase().equals("ios")) {
//            return false;
//        }
        // 30天内未登录过游戏的先排除
        if (userInfo.getLastLoginTime() * DateHelper.SECOND_MILLIONS < System.currentTimeMillis() - 30 * DateHelper.DAY_MILLIONS) {
            return false;
        }

        if (cardId == SceneCardConfig.MonthCard.getCardId()) {
            // 判断是否7天内登录过游戏
            if (userInfo.getLastLoginTime() * DateHelper.SECOND_MILLIONS >= System.currentTimeMillis() - 7 * DateHelper.DAY_MILLIONS) {
                return false;
            }
            UserCard userCard = UserCardBussiness.getUserCard(userInfo.getUserId());
            if (userCard == null) {
                return false;
            }
            return PrivilegeCardMgr.isInCardTime(userCard, eCardType.MonthCard.getValue());
        } else if (cardId == SceneCardConfig.YearCard.getCardId()) {
            // 判断是否7天内登录过游戏
            if (userInfo.getLastLoginTime() * DateHelper.SECOND_MILLIONS >= System.currentTimeMillis() - 7 * DateHelper.DAY_MILLIONS) {
                return false;
            }
            UserCard userCard = UserCardBussiness.getUserCard(userInfo.getUserId());
            if (userCard == null) {
                return false;
            }
            return PrivilegeCardMgr.isInCardTime(userCard, eCardType.YearCard.getValue());
        } else if (cardId == SceneCardConfig.SevenSign.getCardId()) {
            // 是否有解锁七日活动模块的人,没有解锁的人不推送
            return SystemOpenMgr.checkSystemOpen(userInfo.getUserId(), eSystemId.DaySign.getValue());
        }
        return true;
    }

    /*
     * getRewardIndex 特殊处理一些活动和奖励项对应下标
     */
    public static String getRewardIndex(String day, int cardId) {
        if (cardId == SceneCardConfig.SevenSign.getCardId()) {
            if (day.equals("7")) {
                day = "4";
            } else if (day.equals("6")) {
                day = "3";
            } else if (day.equals("5")) {
                day = "2";
            } else {
                day = "1";
            }
        } else if (cardId == SceneCardConfig.MonthCard.getCardId() || cardId == SceneCardConfig.YearCard.getCardId()) {
            day = "1";
        }
        return day;
    }

    /*
     * getRewardCount 特殊处理一些活动和奖励项数量
     */
    public static ArrayList<BigInteger> getRewardCount(String day, int cardId) {
        ArrayList<BigInteger> list = new ArrayList<>();
        if (cardId == SceneCardConfig.SevenSign.getCardId()) {
            if (day.equals("7")) {
                // 联动专属头像框*1+自选宝印*1+珍兽果*5+百业札记*10
                list.add(BigInteger.ONE);
//                list.add(BigInteger.ONE);
//                list.add(BigInteger.valueOf(5));
//                list.add(BigInteger.ONE);
            } else if (day.equals("6")) {
                // 珍兽雄鹰*1+声望卡*1+市井手记*20+病人手册*3
                list.add(BigInteger.ONE);
//                list.add(BigInteger.ONE);
//                list.add(BigInteger.valueOf(20));
//                list.add(BigInteger.valueOf(3));
            } else if (day.equals("5")) {
                // 门客残帖*1+招募金卡*10+卓越突破箱*1+刻钟卡*20
                list.add(BigInteger.ONE);
//                list.add(BigInteger.valueOf(10));
//                list.add(BigInteger.ONE);
//                list.add(BigInteger.valueOf(20));
            } else {
                // 门客甄嬛*1+小资质丹*5+体力丹*10+精力丹*10
                list.add(BigInteger.ONE);
//                list.add(BigInteger.valueOf(5));
//                list.add(BigInteger.valueOf(10));
//                list.add(BigInteger.valueOf(10));
            }
        } else {
            // 奖励：元宝x100，银两*1h收益
            list.add(BigInteger.valueOf(100));
        }
        return list;
    }

    /*
     * getPlayerRewardData 封装一些奖励
     */
    public static PlayerRewardData getPlayerRewardData(List<BigInteger> list, String day, ArrayList<Long> uids) {
        PlayerRewardData rewardData = new PlayerRewardData();
        rewardData.setUids(uids);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("reward_index", day);
        String rewardCount = "[";
        int i = 0;
        for (BigInteger num : list) {
            i++;
            rewardCount += num;
            if (i < list.size()) {
                rewardCount += ",";
            }
        }
        rewardCount += "]";
        jsonObject.put("reward_count", rewardCount);
        rewardData.setRewardData(jsonObject);
        return rewardData;
    }

    /**
     * 发送玩家卡片消息
     * 1.玩家在线就不推送
     */
    public static synchronized boolean sendSceneCard(SceneCardConfig templateConfig, PlayerRewardData playerRewardData) {
        try {
            messageSendExecutor.execute(() -> {
                for (int aid : templateConfig.getAid()) {
                    sendMessageSubscribe(templateConfig, aid, playerRewardData, false);
                }
            });
            return true;
        } catch (Throwable e) {
            logger.error("抖音场景游戏消息推送失败 cardId:{}", templateConfig.getCardId(), e);
        }
        return false;
    }

    /**
     * 推送游戏场景卡片消息 (需要异步调用)
     *
     * @param templateConfig
     * @param aid              需要下发的宿主端ID，抖音传1，抖音极速版传2
     * @param playerRewardData (37 用户 Id 集合,对应用户的奖励)
     */
    private static void sendMessageSubscribe(SceneCardConfig templateConfig, int aid, PlayerRewardData playerRewardData, boolean isRetry) {
        if (!isSwitch()) {
            return;
        }
        if (playerRewardData.getUids().isEmpty()) {
            return;
        }
        try {
            String url = "https://gapih5.37.com/api/v1/dy/pushFeedCard";
            Map<String, String> headerMap = new HashMap<>();
            headerMap.put("content-type", "application/json");

            JSONObject paramObj = new JSONObject();

            int now = DateHelper.getCurrentSecond();
            paramObj.put("aid", aid);
            paramObj.put("uids", playerRewardData.getUids());
            paramObj.put("game_id", gameId);
            paramObj.put("card_id", templateConfig.getCardId());
            paramObj.put("data", playerRewardData.getRewardData());
            paramObj.put("time", now);
            StringBuffer signStr = new StringBuffer();
            signStr.append("aid=").append(aid).append("&")
                    .append("card_id=").append(templateConfig.getCardId()).append("&")
                    .append("game_id=").append(gameId).append("&")
                    .append("time=").append(now).append("&")
                    .append(sign);
            String sign = MD5Security.md5(signStr.toString()).toLowerCase();
            paramObj.put("sign", sign);
            String result = HttpHelper.doPostJson(url, paramObj.toJSONString(), "UTF-8", headerMap);
            if (null == result) {
                logger.info("发送游戏场景卡片消息异常。 url:{}, paramObj:{}", url, paramObj.toJSONString());
                return;
            }
            JSONObject resultObject = JSONObject.parseObject(result);
            JSONObject data = resultObject.getJSONObject("data");
            if (data == null) {
                logger.info("SceneCardMgr 发送游戏场景卡片消息异常 result:{}, cardId:{}, type:{}", result, templateConfig.getCardId(), templateConfig.getGameTitle());
                return;
            }
            int errCode = data.getIntValue("err_no");
            String logId = data.getString("log_id");
            switch (errCode) {
                case SceneCardErrorCode.InternalServerError:
                    if (!isRetry) {
                        // 重新请求
                        sendMessageSubscribe(templateConfig, aid, playerRewardData, true);
                        return;
                    }
                    break;
                case SceneCardErrorCode.PushLimitError:
                    // 触发推送上限直接返回
                    logger.warn("推送消息失败,触发推送上限 cardId:{}, aid:{}, openId:{}, errCode:{}, errMsg:{}, logId:{}", templateConfig.getCardId(), aid, playerRewardData.getUids(), errCode, resultObject.getJSONObject("err_msg"), logId);
                    break;
                default:
                    if (errCode != 0) {
                        logger.warn("推送消息失败 cardId:{}, aid:{}, openId:{}, errCode:{}, logId:{}", templateConfig.getCardId(), aid, playerRewardData.getUids(), errCode, logId);
                        return;
                    }
                    logger.info("推送游戏{}卡片成功 宿主版本：{} ,isRetry :{}, push_result:{}", templateConfig.getGameTitle(), aid, isRetry, data.getJSONObject("data"));
                    break;
            }
        } catch (Exception e) {
            logger.error("推送消息异常 cardId:{},  aid:{} openId:{}", templateConfig.getCardId(), aid, playerRewardData.getUids(), e);
        }
    }

    private static SceneCardPlayerData getCardSubscribeData(int cardId) {
        SceneCardPlayerData sceneCardPlayerData = cardSubscribeMap.get(cardId);
        if (sceneCardPlayerData == null) {
            sceneCardPlayerData = new SceneCardPlayerData();
            sceneCardPlayerData.setCardId(cardId);
            sceneCardPlayerData.setInsertOption();
            cardSubscribeMap.put(cardId, sceneCardPlayerData);
        }
        return sceneCardPlayerData;
    }

    public static void main(String[] args) {
        long serverId = ConfigHelper.getLong("serverId");
//        int channelId = ServerListMgr.getChannelId(serverId);
//        if (channelId != 666) {
//            return;
//        }
        String day = "1";
        List<BigInteger> list = new ArrayList<>();
        list.add(BigInteger.valueOf(100));
//        list.add(BigInteger.valueOf(5));
//        list.add(BigInteger.valueOf(10));
//        list.add(BigInteger.valueOf(10));
        ArrayList<Long> openIds = new ArrayList<>();
        openIds.add(2314602169L);

        PlayerRewardData rewardData = new PlayerRewardData();
        rewardData.setUids(openIds);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("reward_index", day);
        jsonObject.put("reward_count", list);
        rewardData.setRewardData(jsonObject);

        SceneCardMgr.sendMessageSubscribe(SceneCardConfig.YearCard, 1, rewardData, false);
    }
}
